//
//  VisualizationExercise.swift
//  HIextractLicve
//
//  Created by HIextractLicve on 2024/12/11.
//

import UIKit
import ProgressHUD
class VisualizationExercise: UIViewController,UINavigationControllerDelegate, UIImagePickerControllerDelegate {

    @IBOutlet weak var mineIdInfoSowing: UILabel!
    
    var eachVioViewHTLC:THLCNOrBUTTOn?
    var mindfulnessPageHTL:THLCNPageControll?
    var journeyHTLC:UIView?
    @IBOutlet weak var shinweHeaderHTLC: UIImageView!
   
    @IBOutlet weak var namerrEnterTefHTLC: UITextField!
    
    @IBOutlet weak var birthrEnterTefHTLC: UITextField!
    
    @IBOutlet weak var abountEnterTefHTLC: UITextField!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        shinweHeaderHTLC.layer.cornerRadius = 20
        shinweHeaderHTLC.layer.masksToBounds = true
        shinweHeaderHTLC.contentMode = .scaleAspectFill
        self.mineIdInfoSowing.text = "ID: " + (HTLCAllDealRelaxing.Relaxing.signinUserDataHTL["natureImmersion"] ?? "")
        if self.navigationController?.navigationBar.isHidden == true {
            journeyHTLC?.alpha = 1
            journeyHTLC?.layer.cornerRadius = 12
        }
        journeyHTLC?.backgroundColor = UIColor(red: 0.06, green: 0.07, blue: 0.07, alpha: 0.01)

        eachVioViewHTLC = THLCNOrBUTTOn.init()
        eachVioViewHTLC?.setTitle("anchors", for: .normal)
        if journeyHTLC != nil {
            journeyHTLC?.addSubview(eachVioViewHTLC ?? THLCNOrBUTTOn.init())
            view.addSubview(journeyHTLC!)
        }

        mindfulnessPageHTL = THLCNPageControll()
        mindfulnessPageHTL?.numberOfPages = 1
        mindfulnessPageHTL?.backgroundColor = UIColor(red: 0.06, green: 0.07, blue: 0.07, alpha: 0.01)
        mindfulnessPageHTL?.tintColor = UIColor(red: 0.06, green: 0.07, blue: 0.07, alpha: 0.01)
        mindfulnessPageHTL?.sizeToFit()

        if journeyHTLC != nil {
            journeyHTLC?.addSubview(mindfulnessPageHTL ?? THLCNPageControll.init())
           
        }
        namerrEnterTefHTLC.text =  HTLCAllDealRelaxing.Relaxing.signinUserDataHTL["HTLCkiName"]
        shinweHeaderHTLC.image = HTLCAllDealRelaxing.Relaxing.showingHTLimgHead
        birthrEnterTefHTLC.text = HTLCAllDealRelaxing.Relaxing.signinUserDataHTL["HTLCborn"]
        abountEnterTefHTLC.text = HTLCAllDealRelaxing.Relaxing.signinUserDataHTL["HTLCbrief"]
        
    }


    @IBAction func bafanhuiNowHTLC(_ sender: Any) {
       
            self.navigationController?.popViewController(animated: true)
        
        
    }
   

    @IBAction func takePhotoFirHeader(_ sender: UIButton) {
      
       
        if UIImagePickerController.isSourceTypeAvailable(.camera) {
            let photoPicker = UIImagePickerController()
            photoPicker.delegate = self
            
            photoPicker.allowsEditing = false
           
            photoPicker.sourceType = .camera
  
            self.present(photoPicker, animated: true, completion: nil)
            return
        }
            ProgressHUD.banner(HTLROOOMMeasg.BinrwetioBase64("U29ycnksTm8gQ2FtZXJhIHBlcm1pc3Npb24hISE="), HTLROOOMMeasg.BinrwetioBase64("QSBwcm9tcHQgbWVzc2FnZQ=="), delay: 2.0)
          
        
        
    }
    
    @IBAction func saveChangeinfToucHTlc(_ sender: Any) {
        guard let emiajkgVAF = namerrEnterTefHTLC.text,
              emiajkgVAF.count != 0 else {
        
            ProgressHUD.banner(HTLROOOMMeasg.BinrwetioBase64("RW1wdHkgbmFtZSBjYW5ub3QgYmUgc2F2ZWQhISE="), HTLROOOMMeasg.BinrwetioBase64("QSBwcm9tcHQgbWVzc2FnZQ=="), delay: 2.0)
            return
        }
        
       
        HTLCAllDealRelaxing.Relaxing.signinUserDataHTL["HTLCkiName"] = emiajkgVAF
        HTLCAllDealRelaxing.Relaxing.signinUserDataHTL["HTLCbrief"] = self.abountEnterTefHTLC.text
        HTLCAllDealRelaxing.Relaxing.signinUserDataHTL["HTLCborn"] = self.birthrEnterTefHTLC.text
      
       
        
        
        HTLCAllDealRelaxing.Relaxing.showingHTLimgHead = self.shinweHeaderHTLC.image
            
      
        ProgressHUD.animate()
        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1.5, execute: DispatchWorkItem(block: {
            ProgressHUD.succeed(HTLROOOMMeasg.BinrwetioBase64("Q2hhbmdlIGFjY291bnQgaW5mbyBzdWNjZXNzZWQhISE="), delay: 2.5)
           
            self.navigationController?.popViewController(animated: true)
        }))

       

        
        
    }
    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
     
            picker.dismiss(animated: true)
        
        
    }
    
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
      
       
        let image : UIImage? = info[UIImagePickerController.InfoKey.originalImage] as? UIImage
       
        DispatchQueue.main.async {
            picker.dismiss(animated: true)
            
            self.shinweHeaderHTLC.image = image
          
           
        }
        
    }
}
